<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #search-Text {
            color: #ccc;
        }
    </style>
</head>
<body>
    <input type="text" id="search-Text" value="请输入关键字">
    <script>
        let search_Text = document.getElementById("search-Text");
        let search_Text_StartValue = search_Text.value; // 获取默认初始值
        search_Text.onfocus = function(){
            if(search_Text.value === search_Text_StartValue){
                search_Text.value = "";
                search_Text.style.color = "black";
            }
            
        };
        search_Text.onblur = function(){
            if(search_Text.value == search_Text_StartValue || search_Text.value == ""){
                search_Text.style.color = "#ccc";
                search_Text.value = search_Text_StartValue;
            }
        };
        console.log(search_Text_StartValue);
    </script>
</body>
</html>